﻿<Window x:Class="SBattle.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:SBattle.UI"
        xmlns:aero="clr-namespace:Common.AeroGlass;assembly=Common"
        aero:GlassEffect.IsEnabled="True" 
        MouseLeftButtonDown="Window_MouseLeftButtonDown"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="SBattle - lobby" Height="330" Width="522">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="5" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Grid.Column="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="5" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
                <RowDefinition Height="5" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Content="Players online: " />
            <ListView Grid.Column="0" Grid.Row="1" Grid.RowSpan="3" ItemsSource="{Binding Client.PlayersOnline}">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Name" Width="100" DisplayMemberBinding="{Binding Name}" />
                        <GridViewColumn Header="" Width="100">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Label HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding Status}" />
                                        <Button Content="Play!" Click="btnPlay_Click"
                                                Visibility="{Binding ReadyForGame, Converter={my:BooleanToVisibilityConverter}}" />
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>

            <Label Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" Content="Current games: " />
            <ListView Grid.Column="2" Grid.Row="1" ItemsSource="{Binding Client.CurrentGames}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>

                            <Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" Content="{Binding NameA}" />
                            <Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" Content="{Binding ScoresA}" />

                            <Label Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Content="vs" />

                            <Label Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" Content="{Binding NameB}" />
                            <Label Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" Content="{Binding ScoresB}" />
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <Grid Grid.Column="2" Grid.Row="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition />
                    <ColumnDefinition Width="5" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                
                <Label Grid.Column="0" Content="Password: " />

                <PasswordBox Grid.Column="1" PasswordChar="*" Name="pwdPassword" />

                <Button Grid.Column="3" Content="Expect for game" HorizontalAlignment="Stretch" 
                    Click="btnExpectForGame_Click" Name="btnExpectForGame"/>
                <Button Grid.Column="3" Content="Cancel expectation" HorizontalAlignment="Stretch"
                    Visibility="Hidden" Click="btnCancelExpectation_Click" Name="btnCancelExpectation"/>
            </Grid>
        </Grid>

        <GridSplitter Grid.Row="1" Grid.Column="0" Background="Transparent"
                      ResizeDirection="Rows" ResizeBehavior="PreviousAndNext"
                      VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>

        <my:ChatFrame Grid.Row="2" Grid.Column="0" Client="{Binding Client}" x:Name="chat" />
    </Grid>
</Window>
